<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
	<title>E8NET</title>

	<meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <!-- bootstrap -->
<link href="/dianm/Public/Admin/css/bootstrap/bootstrap.css" rel="stylesheet" />
<link href="/dianm/Public/Admin/css/bootstrap/bootstrap-responsive.css" rel="stylesheet" />
<link href="/dianm/Public/Admin/css/bootstrap/bootstrap-overrides.css" type="text/css" rel="stylesheet" />

<!-- global styles -->
<link rel="stylesheet" type="text/css" href="/dianm/Public/Admin/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/dianm/Public/Admin/css/elements.css" />
<link rel="stylesheet" type="text/css" href="/dianm/Public/Admin/css/icons.css" />

<!-- libraries -->
<link href="/dianm/Public/Admin/css/lib/bootstrap-wysihtml5.css" type="text/css" rel="stylesheet" />
<link href="/dianm/Public/Admin/css/lib/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" />
<link href="/dianm/Public/Admin/css/lib/font-awesome.css" type="text/css" rel="stylesheet" />
<link href="/dianm/Public/Admin/css/lib/morris.css" type="text/css" rel="stylesheet" />
<link href="/dianm/Public/Admin/css/popup.css" type="text/css" rel="stylesheet" />



<!-- open sans font -->
<!--<link href='http://fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css' />-->

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<link href="/dianm/Public/Libs/confirm/jquery.confirm.css" type="text/css" rel="stylesheet" />


    <!-- this page specific styles -->
    <link href="/dianm/Public/Admin/css/lib/select2.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="/dianm/Public/Admin/css/compiled/form-wizard.css" type="text/css" media="screen" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

    <!-- navbar -->
<div class="navbar navbar-inverse">
    <div class="navbar-inner">
        <button type="button" class="btn btn-navbar visible-phone" id="menu-toggler">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <a class="brand" href="index.html"><img src="" /></a>

        <ul class="nav pull-right">
            <li class="hidden-phone">
                <input class="search" type="text" />
            </li>


            <!-- 消息提醒 -->
            <li class="notification-dropdown hidden-phone">
                <a href="#" class="trigger">
                    <i class="icon-envelope-alt"></i>
                    <span class="count">8</span>
                </a>
                <div class="pop-dialog">
                    <div class="pointer right">
                        <div class="arrow"></div>
                        <div class="arrow_border"></div>
                    </div>
                    <div class="body">
                        <a href="#" class="close-icon"><i class="icon-remove-sign"></i></a>
                        <div class="messages">

                        </div>
                    </div>
                </div>
            </li>


            <!-- 个人菜单 -->
            <li class="dropdown">
                <a href="#" class="dropdown-toggle hidden-phone" data-toggle="dropdown">
                    <?php echo ($_SESSION['admin']['tname']); ?>
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="<?php echo U('Public/editPersonalInfo');?>">修改个人资料</a></li>
                    <li><a href="<?php echo U('Public/logout');?>">退出登录</a></li>
                </ul>
            </li>

            <!-- 前台首页 -->
            <li class="settings hidden-phone">
                <a href="/dianm" role="button">
                    <i class="icon-globe"></i>
                </a>
            </li>
        </ul>
    </div>
</div>
<!-- end navbar -->
    <!-- sidebar -->
<div id="sidebar-nav">
    <ul id="dashboard-menu">

        <?php if(is_array($menu)): $i = 0; $__LIST__ = $menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$m): $mod = ($i % 2 );++$i;?><li class="<?php echo ($m["active"]); ?>">

                <?php if($m["active"] == 'active'): ?><div class="pointer">
                        <div class="arrow"></div>
                        <div class="arrow_border"></div>
                    </div><?php endif; ?>

                <a <?php if($m["child"] != ''): ?>class="dropdown-toggle"<?php endif; ?>  href="<?php echo ($m["url"]); ?>">
                    <i class="<?php echo ($m["icon"]); ?>"></i>
                    <span><?php echo ($m["text"]); ?></span>
                    <?php if($m["child"] != ''): ?><i class="icon-chevron-down"></i><?php endif; ?>
                </a>

                <?php if($m["child"] != ''): ?><ul class="<?php echo ($m["active"]); ?> submenu">
                        <?php if(is_array($m["child"])): $i = 0; $__LIST__ = $m["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i;?><li><a href="<?php echo ($c["url"]); ?>" class="<?php echo ($c["active"]); ?>"><?php echo ($c["text"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
                    </ul><?php endif; ?>
            </li><?php endforeach; endif; else: echo "" ;endif; ?>

    </ul>
</div>
<!-- end sidebar -->


	<!-- main container -->
    <div class="content">

        <div class="container-fluid">
            <div id="pad-wrapper">
                <!-- <div class="row-fluid head">
                    <div class="span12">
                        <h4>Form wizard</h4>
                    </div>
                </div> -->
                <div class="row-fluid">
                    <div class="span12">
                        <div id="fuelux-wizard" class="wizard row-fluid" style="text-align: center">
                            <ul class="wizard-steps">
                                <li data-target="#step1" class="active">
                                    <span class="step">1</span>
                                    <span class="title">修改教学计划名称 </span>
                                </li>
                                <li data-target="#step2">
                                    <span class="step">2</span>
                                    <span class="title">重新选择一门课程 </span>
                                </li>
                                <li data-target="#step3">
                                    <span class="step">3</span>
                                    <span class="title">修改教学计划课表 </span>
                                </li>
                                <li data-target="#step4">
                                    <span class="step">4</span>
                                    <span class="title">修改上课学生 </span>
                                </li>
                            </ul>                            
                        </div>
                        <form id="plan-form">
                        <input type="hidden" name="id" value="<?php echo ($teachplan["id"]); ?>" />
                        <div class="step-content">
                            <div class="step-pane active" id="step1">
                                <div class="row-fluid form-wrapper">
                                    <div class="span6 offset3">
                                        <div class="field-box">
                                            <label>教学计划名称:</label>
                                            <input class="span9 inline-input" name="name" value="<?php echo ($teachplan["name"]); ?>" placeholder="请输入教学计划名称,如C语言程序设计教学计划" type="text" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="step-pane" id="step2">
                                <div class="row-fluid form-wrapper">
                                    <div class="span6 offset3">
                                        <div class="field-box">
                                            <label>计划教学课程:</label>
                                            <select class="select2 span8" name="course_id">
                                                <option value="" />
                                                <?php if(is_array($courseList)): $i = 0; $__LIST__ = $courseList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$course): $mod = ($i % 2 );++$i;?><option <?php if($teachplan['course_id'] == $course['id']): ?>selected<?php endif; ?> value="<?php echo ($course["id"]); ?>" /> <?php echo ($course["name"]); endforeach; endif; else: echo "" ;endif; ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="step-pane" id="step3">
                                <div class="row-fluid form-wrapper">

                                    <div class="span8 offset2">
                                        <table class="table table-hover">
                                            <thead>
                                            <tr>
                                                <th class="span2">
                                                    周次
                                                </th>
                                                <th class="span2">
                                                    <span class="line"></span>
                                                    星期
                                                </th>
                                                <th class="span2">
                                                    <span class="line"></span>
                                                    开始节次
                                                </th>
                                                <th class="span2">
                                                    <span class="line"></span>
                                                    结束节次
                                                </th>
                                                <th class="span2">
                                                    <span class="line"></span>
                                                    上课地点
                                                </th>
                                                <th class="span2 align-right">
                                                    <span class="line"></span>
                                                    ACTION
                                                </th>
                                            </tr>
                                            </thead>
                                            <tbody id="courseBody">
                                            <!-- row -->
                                                <?php if(is_array($timetableList)): $i = 0; $__LIST__ = $timetableList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$timetable): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($timetable["id"]); ?>">
                                                        <td>第<?php echo ($timetable["week"]); ?>周</td>
                                                        <td>星期<?php echo ($timetable["xq"]); ?></td>
                                                        <td>从第<?php echo ($timetable["start"]); ?>节开始</td>
                                                        <td>到第<?php echo ($timetable["end"]); ?>节结束</td>
                                                        <td>上课地点 <?php echo ($timetable["address"]); ?></td>
                                                        <td class='align-right'><a href='javascript:delTr("<?php echo ($timetable["id"]); ?>");' >Delete</a></td>

                                                        <input type='hidden' name='week[]' value='<?php echo ($timetable["week"]); ?>' />
                                                        <input type='hidden' name='xq[]' value='<?php echo ($timetable["xq"]); ?>' />
                                                        <input type='hidden' name='start[]' value='<?php echo ($timetable["start"]); ?>' />
                                                        <input type='hidden' name='end[]' value='<?php echo ($timetable["end"]); ?>' />
                                                        <input type='hidden' name='address[]' value='<?php echo ($timetable["address"]); ?>' />
                                                    </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                                            </tbody>
                                        </table>

                                        <div class="row-fluid filter-block">
                                            <div class="pull-right">
                                                <!-- custom popup filter -->
                                                <!-- styles are located in css/elements.css -->
                                                <!-- script that enables this dropdown is located in js/theme.js -->
                                                <div class="ui-dropdown">
                                                    <div class="head" data-toggle="tooltip" title="">
                                                        添加课表
                                                        <i class="arrow-down"></i>
                                                    </div>
                                                    <div class="dialog">
                                                        <div class="pointer">
                                                            <div class="arrow"></div>
                                                            <div class="arrow_border"></div>
                                                        </div>
                                                        <div class="body">
                                                            <p class="title">
                                                                请填写课表信息 ( 当前学期 <span style="color: darkred"><?php echo ($_SESSION['term']['detail']); ?></span> )
                                                            </p>
                                                            <div class="form">
                                                                <div class="ui-select" style="width:100px;">
                                                                    <select id="week">
                                                                        <option value="" selected="" /> 选择周次
                                                                        <?php $__FOR_START_1682795647__=1;$__FOR_END_1682795647__=21;for($weeknum=$__FOR_START_1682795647__;$weeknum < $__FOR_END_1682795647__;$weeknum+=1){ ?><option value="<?php echo ($weeknum); ?>" /> 第<?php echo ($weeknum); ?>周<?php } ?>
                                                                    </select>
                                                                </div>
                                                                <div class="ui-select" style="width:100px;">
                                                                    <select id="xq">
                                                                        <option value="" selected="" /> 选择星期
                                                                        <?php $__FOR_START_623114574__=1;$__FOR_END_623114574__=8;for($xqnum=$__FOR_START_623114574__;$xqnum < $__FOR_END_623114574__;$xqnum+=1){ ?><option value="<?php echo ($xqnum); ?>" /> 星期<?php echo ($xqnum); } ?>
                                                                    </select>
                                                                </div>
                                                                <div class="ui-select" style="width:100px;">
                                                                    <select id="start">
                                                                        <option value="" selected="" /> 开始节次
                                                                        <option value="0" /> 晨操
                                                                        <?php $__FOR_START_1500031751__=1;$__FOR_END_1500031751__=12;for($startnum=$__FOR_START_1500031751__;$startnum < $__FOR_END_1500031751__;$startnum+=1){ ?><option value="<?php echo ($startnum); ?>" /> 从第<?php echo ($startnum); ?>节开始<?php } ?>
                                                                    </select>
                                                                </div>
                                                                <div class="ui-select" style="width:100px;">
                                                                    <select id="end">
                                                                        <option value="" selected="" /> 结束节次
                                                                        <option value="0" /> 晨操
                                                                        <?php $__FOR_START_282286633__=1;$__FOR_END_282286633__=12;for($endnum=$__FOR_START_282286633__;$endnum < $__FOR_END_282286633__;$endnum+=1){ ?><option value="<?php echo ($endnum); ?>" /> 到第<?php echo ($endnum); ?>节结束<?php } ?>
                                                                    </select>
                                                                </div>

                                                                <p style="padding: 15px 0 0 0">
                                                                    <input class="inline-input" id="address" type="text" placeholder="请输入上课地址" /> &nbsp;&nbsp;&nbsp;
                                                                    <a href="javascript:addTimetable();" class="btn-flat gray small" style="padding: 4px 14px;">+ 添加课表</a>
                                                                </p>

                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div class="step-pane" id="step4">
                                <div class="row-fluid form-wrapper payment-info">
                                    <div class="span8 offset2">
                                        <table class="table table-hover">
                                            <thead>
                                            <tr>
                                                <th class="span2">
                                                    学生姓名
                                                </th>
                                                <th class="span2">
                                                    <span class="line"></span>
                                                    所属班级
                                                </th>
                                                <th class="span2 align-right">
                                                    <span class="line"></span>
                                                    ACTION
                                                </th>
                                            </tr>
                                            </thead>
                                            <tbody id="studentBody">
                                            <!-- row -->
                                            <?php if(is_array($studentList)): $i = 0; $__LIST__ = $studentList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$student): $mod = ($i % 2 );++$i;?><tr id="<?php echo ($student["student_id"]); ?>">
                                                    <td><?php echo ($student["name"]); ?></td>
                                                    <td><?php echo ($student["class_name"]); ?></td>
                                                    <td class='align-right'><a href='javascript:delTr("<?php echo ($student["student_id"]); ?>");' >Delete</a></td>
                                                    <input type="hidden" name="student_id[]" value="<?php echo ($student["id"]); ?>" />
                                                </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                                            </tbody>
                                        </table>

                                        <div class="row-fluid filter-block">
                                            <div class="pull-right">
                                                <!-- custom popup filter -->
                                                <!-- styles are located in css/elements.css -->
                                                <!-- script that enables this dropdown is located in js/theme.js -->
                                                <div class="ui-dropdown">
                                                    <div class="head" data-toggle="tooltip" title="">
                                                        添加学生
                                                        <i class="arrow-down"></i>
                                                    </div>
                                                    <div class="dialog">
                                                        <div class="pointer">
                                                            <div class="arrow"></div>
                                                            <div class="arrow_border"></div>
                                                        </div>
                                                        <div class="body">
                                                            <p class="title">
                                                                请选择相应学生
                                                            </p>
                                                            <div class="form" style="padding-bottom: 5px;">
                                                                <select id="classSelector" class="select2 span4" onchange="classChange();">
                                                                    <option selected /> 选择一个班级
                                                                    <?php if(is_array($classList)): $i = 0; $__LIST__ = $classList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$class): $mod = ($i % 2 );++$i;?><option value="<?php echo ($class["id"]); ?>" /> <?php echo ($class["name"]); endforeach; endif; else: echo "" ;endif; ?>

                                                                </select>

                                                                <select id="studentSelector" multiple="" class="select2 span5">
                                                                </select>
                                                                &nbsp;&nbsp;&nbsp;
                                                                <a href="javascript:addStudent();" class="btn-flat gray small" style="padding: 4px 14px; margin-top:3px;">+ 添加学生</a>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                        </form>
                        <div class="wizard-actions">
                            <button type="button" disabled="" class="btn-flat info btn-prev">
                                <i class="icon-chevron-left"></i> 上一步
                            </button>
                            <button type="button" class="btn-flat info btn-next" data-last="Finish">
                                下一步 <i class="icon-chevron-right"></i>
                            </button>
                            <button type="button" class="btn-flat success btn-finish" onclick="submitForm('plan-form','/dianm/admin.php/Teachplan/edit');" >
                                完成提交
                            </button>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <!-- end main container -->




	<!-- scripts for this page -->
    <!-- scripts for this page -->
<script src="/dianm/Public/Admin/js/wysihtml5-0.3.0.js"></script>
<script src="/dianm/Public/Admin/js/jquery-latest.js"></script>
<script src="/dianm/Public/Admin/js/bootstrap.min.js"></script>
<script src="/dianm/Public/Admin/js/bootstrap-wysihtml5-0.0.2.js"></script>
<script src="/dianm/Public/Admin/js/jquery-ui-1.10.2.custom.min.js"></script>
<!-- knob -->
<script src="/dianm/Public/Admin/js/jquery.knob.js"></script>
<!-- flot charts -->
<script src="/dianm/Public/Admin/js/jquery.flot.js"></script>
<script src="/dianm/Public/Admin/js/jquery.flot.stack.js"></script>
<script src="/dianm/Public/Admin/js/jquery.flot.resize.js"></script>
<!-- morrisjs -->
<script src="/dianm/Public/Admin/js/raphael-min.js"></script>
<script src="/dianm/Public/Admin/js/morris.min.js"></script>
<!-- call all plugins -->
<script src="/dianm/Public/Admin/js/theme.js"></script>

<script src="/dianm/Public/Admin/js/tools.js"></script>
<script src="/dianm/Public/Libs/confirm/jquery.confirm.js"></script>

    <script src="/dianm/Public/Admin/js/fuelux.wizard.js"></script>
    <script src="/dianm/Public/Admin/js/select2.min.js"></script>

    <script type="text/javascript">
        $(function () {
            var $wizard = $('#fuelux-wizard'),
                $btnPrev = $('.wizard-actions .btn-prev'),
                $btnNext = $('.wizard-actions .btn-next'),
                $btnFinish = $(".wizard-actions .btn-finish");

            $wizard.wizard().on('finished', function(e) {
                // wizard complete code
            }).on("changed", function(e) {
                var step = $wizard.wizard("selectedItem");
                // reset states
                $btnNext.removeAttr("disabled");
                $btnPrev.removeAttr("disabled");
                $btnNext.show();
                $btnFinish.hide();

                if (step.step === 1) {
                    $btnPrev.attr("disabled", "disabled");
                } else if (step.step === 4) {
                    $btnNext.hide();
                    $btnFinish.show();
                }
            });

            $btnPrev.on('click', function() {
                $wizard.wizard('previous');
            });
            $btnNext.on('click', function() {
                $wizard.wizard('next');
            });


            $(".select2").select2({
                placeholder: "请选择一个选项"
            });
        });


        function addTimetable() {

            var _week = $('#week').val();
            var _xq = $('#xq').val();
            var _start = $('#start').val();
            var _end = $('#end').val();
            var _address = $('#address').val();

            if (_week == '' || _xq == '' || _start == '' || _end == '' || _address == '') {
                alert('请填写完整的信息后再点击添加按钮');
                return;
            }

            var id = new Date().getTime();
            var html = "<tr id='"+ id +"'>"
                        + "<td>第"+_week+"周</td>"
                        + "<td>星期"+_xq+"</td>"
                        + "<td>从第"+_start+"节开始</td>"
                        + "<td>到第"+_end+"节结束</td>"
                        + "<td>上课地点 "+_address+"</td>"
                        + "<td class='align-right'><a href='javascript:delTr("+id+");' >Delete</a></td>"
                        + "<input type='hidden' name='week[]' value='" +_week+ "' />"
                        + "<input type='hidden' name='xq[]' value='" +_xq+ "' />"
                        + "<input type='hidden' name='start[]' value='" +_start+ "' />"
                        + "<input type='hidden' name='end[]' value='" +_end+ "' />"
                        + "<input type='hidden' name='address[]' value='" +_address+ "' />"
                        + "</tr>";
            $('#courseBody').append(html);
        }


        function addStudent() {

            var cid = $('#classSelector').val();   // 当前选中班级id
            var cname = $('#classSelector').find("option:selected").text();  // 当前选中班级名称
            var sids = $('#studentSelector').val();  // 所有选择的学生id集合
            var snames = $('#studentSelector').find("option:selected").text();  // 所有选择的学生姓名集合

            if (sids == '' || sids == null) {
                alert('请选择一些学生后再点击添加按钮');
                return;
            }

            var id = new Date().getTime();
            var html = '';

            var sidArr = (sids + '').split(',');


            // 如果选择了所有学生
            if (sidArr.in_array(0)) {
                html = "<tr id='"+ id +"'>"
                        + "<td>所有学生</td>"
                        + "<td>"+cname+"</td>"
                        + "<td class='align-right'><a href='javascript:delTr("+id+");' >Delete</a></td>"
                        + "<input type='hidden' name='class_id[]' value='" +cid+ "' />"
                        + "</tr>";

                $('#studentBody').append(html);
            } else {

                var snameArr = (snames.substr(0,snames.length - 1)).split(',');
                for (var i=0; i<sidArr.length; i++) {
                    html = "<tr id='"+ id +"'>"
                            + "<td>"+snameArr[i]+"</td>"
                            + "<td>"+cname+"</td>"
                            + "<td class='align-right'><a href='javascript:delTr("+id+");' >Delete</a></td>"
                            + "<input type='hidden' name='student_id[]' value='" +sidArr[i]+ "' />"
                            + "</tr>";
                    $('#studentBody').append(html);
                }
            }

        }


        function classChange() {
            var classid = $('#classSelector').val();
            $.post("<?php echo U('Teachplan/getStudent');?>",{classid:classid},function(result){
                var obj = eval('(' + result + ')');
                if (obj.result == 'RESULT_OK') {
                    var studentObj = document.getElementById("studentSelector");
                    studentObj.innerHTML = "";
                    // 将获取到得学生写入select
                    var opp;
                    opp = new Option('选择全部','0');
                    studentObj.add(opp);
                    $.each(obj.data, function(index,item){
                        opp = new Option(item.name+',',item.id);
                        studentObj.add(opp);
                    });
                } else {
                    alert(obj.msg);
                }
            })
        }

        function delTr(id) {
            $('#' + id).remove();
        }

    </script>

</body>
</html>